<?php

class User_Form_Profile extends Zend_Form
{

    public function init()
    {
        // Create a subform to hold all elements
        $form = new Koncept_Form_SubForm();

        $name = new Zend_Form_Element_Text('username');
        $name->setRequired(true)
            ->setLabel('Username');

        $email = new Koncept_Form_Element_Email('email');
        $email->setRequired(true)
            ->setLabel('E-mail');

        $password = new Zend_Form_Element_Password('password');
        $password->setRequired(true)
            ->setLabel('Password');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Submit');

        $form->addElements(array($name, $email, $password, $submit));

        // Put all elements into a subform to group them in an array on retrival
        $this->addSubForm($form, 'user');

        $this->setMethod('post')
            ->setAction('/user/activate')
            ->setName('accountform');
    }

    public function setAccountId($id = null)
    {
        if($id) {
            $this->setMethod('put')
                ->setAction('/user/account/' . $id);
        } else {
            $this->setMethod('post')
                ->setAction('/user/account');
        }

    }

    public function setUsername($username)
    {
        $this->getSubform('user')->getElement('username')->setValue($username);
    }

    public function setEmail($email)
    {
        $this->getSubform('user')->getElement('email')->setValue($email);
    }

    public function setPassword($password)
    {
        $this->getSubform('user')->getElement('password')->setValue($password);
    }

    public function setValues($user)
    {
        if($user instanceof User_Model_User) {
            
        }
    }

}

